# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libexif
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.6.25
pkgrel=1
pkgdesc="A library to parse an EXIF file and read the data from those tags (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://libexif.github.io/"
msys2_references=(
  "cpe: cpe:/a:libexif:libexif"
  "cpe: cpe:/a:libexif_project:libexif"
)
license=("LGPL-2.1")
makedepends=("${MINGW_PACKAGE_PREFIX}-pkgconf" "${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-gettext-tools")
depends=("${MINGW_PACKAGE_PREFIX}-gettext-runtime")
source=(https://github.com/libexif/libexif/archive/libexif-${pkgver//./_}-release.tar.gz)
sha256sums=('ee0795432c20d2fdb2a8a579dd6fc0e19d402e36f14f42c03ab60d2345950f09')

prepare() {
  cd "${srcdir}"/${_realname}-${_realname}-${pkgver//./_}-release
  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}-${_realname}-${pkgver//./_}-release/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --disable-docs \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  install -Dm644 "${srcdir}/${_realname}-${_realname}-${pkgver//./_}-release/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
